package com.heyqing.ems.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.heyqing.ems.common.MemberType;
import com.heyqing.ems.domain.BossInfo;
import com.heyqing.ems.domain.EmployeeInfo;
import com.heyqing.ems.domain.ManagerInfo;
import com.heyqing.ems.service.BossService;
import com.heyqing.ems.service.EmployeeService;
import com.heyqing.ems.service.ManagerService;
import com.heyqing.ems.service.MesosphereService;
import com.heyqing.ems.vo.AvatarVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * ClassName:MesosphereServiceImpl
 * Package:com.heyqing.ems.service.impl
 * Description:
 *
 * @Date:2024/6/27
 * @Author:Heyqing
 */
@Service
@RequiredArgsConstructor
public class MesosphereServiceImpl implements MesosphereService {
    private final BossService bossService;
    private final ManagerService managerService;
    private final EmployeeService employeeService;

    @Override
    public AvatarVo getIdAndName(String type, Long id) {
        AvatarVo avatarVo = new AvatarVo();
        if (type.equals(MemberType.BOSS)){
            BossInfo boss = bossService.getById(id);
            BeanUtil.copyProperties(boss,avatarVo);
        }
        if (type.equals(MemberType.MANAGER)){
            ManagerInfo manager = managerService.getById(id);
            BeanUtil.copyProperties(manager,avatarVo);
        }
        if (type.equals(MemberType.EMPLOYEE)){
            EmployeeInfo employee = employeeService.getById(id);
            BeanUtil.copyProperties(employee,avatarVo);
        }
        return avatarVo;
    }
}
